<?php
  class Gi_Registry {
    private static $_vars = array();
    private static $_instance = null;
    
    private function __construct () {
    }
    
    private function __clone () {
    }
    
    public static function get_instance () {
      if (null === self::$_instance){
        self::$_instance = new self();
      }
      return self::$_instance;
    }
    
    public function assign($key,$value) {
      self::$_vars[$key] = $value;
      return this;  
    }
    
    public function get($key = null) {
      if (null === $key)
        return self::$_vars;
      else
        return self::$_vars[$key];
    }
    
    public function __get ($key) {
      return self::get($key);
    }
    
    public function __set($key,$val) {
      return self::assign($key,$val);
    }
    
    public function clear_var ($key){
      unset(self::$_vars[$key]);
      return $this;
    }
  }